package com.cyx.system.test.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.cyx.system.test.domain.TestDomain;
import com.cyx.system.test.mapper.TestMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

public interface ITestService {
    List<?> list();

    String add();

    // Service需要加到类上而不是接口上
    @Service
    class TestServiceImpl implements ITestService {

        @Autowired
        TestMapper testMapper;

        public List<?> list() {
            return testMapper.selectList(new LambdaQueryWrapper());
        }

        @Override
        public String add() {
            TestDomain testDomain = new TestDomain();
            testDomain.setTitle("测试");
            testDomain.setContent("测试主键生成");
            testMapper.insert(testDomain);
            return "测试生成主键成功";
        }
    }
}
